
$(document).ready(function(){
    wireEvents();
})

function wireEvents(){
    $('#btnGet').click(function(){
        getBook();
    });
    
    $('#btnVast').click(function(){
        getTimes();
    });
}

function getBook(){
    $.getJSON("http://localhost:8080/RESTdb/webresources/bookservice/", function(data){
        $('#author').val(data.book[2].author);
        $('#title').val(data.book[2].title);
        $('#year').val(data.book[2].relYear);          
    })      
};

function getTimes(){
    $.getJSON("http://api.vasttrafik.se/bin/rest.exe/departureBoard?authKey=6511154616&id=9021014003760000&format=json&jsonpCallback=?", function (data){
        $('#hallplats').val(data.DepartureBoard.Departure[0].stop);  
    })      
};

